//
//  ViewController.m
//  TestDemo-button
//
//  Created by 李洪攀 on 2018/7/25.
//  Copyright © 2018年 李洪攀. All rights reserved.
//

#import "ViewController.h"
#import "LHPCountDownButton.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    LHPCountDownButton *countDownBtn = [LHPCountDownButton buttonWithType:UIButtonTypeCustom];
    countDownBtn.frame=CGRectMake(100, 100, 100, 100);
    [countDownBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
    countDownBtn.backgroundColor=[UIColor blueColor];
    [self.view addSubview:countDownBtn];
    
    [countDownBtn countDownButtonHandler:^(LHPCountDownButton *countDownButton, NSInteger tag) {
        countDownBtn.enabled = NO;
        
        [countDownBtn startCountDownWithSecond:10.0];
        [countDownBtn countDownChanging:^NSString *(LHPCountDownButton *countDownButton, NSInteger second) {
            NSString *title = [NSString stringWithFormat:@"剩余%ld秒",second];
            return title;
        }];
        [countDownBtn countDownFinished:^NSString *(LHPCountDownButton *countDownButton, NSInteger second) {
            countDownBtn.enabled = YES;
            return @"点击重新获取";
        }];
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

